package com.example.dbsample.model.entity;

import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonIgnore;

import java.time.LocalTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.StringJoiner;

public class GatewayInfo {
    @TableId(
            type = IdType.AUTO
    )
    protected Long id;                      // 网关ID
    protected String name;                  // 网关名称，举例：委外催收OUTSOURCE
    protected Long accountId;               // 可以是固定值，如：outbound=57，inbound=56
    // 测试环境都是0
    protected Integer calleeLimitType;      // 可以是固定值，如：none
    // 测试环境大部分是1
    protected String calleeLimit;           // 可以是固定值，如：none
    // 测试环境大部分是0
    protected Integer callerLimitType;      // 可以是固定值，如：0
    // 如：AI_DUN、NEW_LOAN
    protected String callerLimit;           // 如：OUTSOURCE、XJ_AI_DUN
    // NULL
    private String callerLengthLimit;       // 可以是固定值，如：none
    // NULL
    private String calleeLengthLimit;       // 可以是固定值，如：none
    // outbound为空
    // inbound诸如：*:10108066;02568364555
    private String callerChange;            // 主机号码变换，举例：【*:10108000】、【0256364555】、【*:075533059458】
    // 举例：空；【:9001】；【02568364532:in001】
    private String calleeChange;            // 被叫前缀变换，举例：【:92】
    // 网关并发限制 0-不限制（？），作为每个场景的空闲并发数
    // 如：POST_LOAN_DUN的并发数=400
    // 同一个场景的进线、出线并发数要加起来？
    private Integer concurrency = 0;
    // 测试环境基本是1
    private Integer priority;               // 优先级
    // 00:00:00
    private LocalTime callTimeStart;        // 禁呼开始时间
    // 23:59:00
    private LocalTime callTimeEnd;          // 禁呼结束时间
    @TableField(
            exist = false
    )
    private List<String> fsServerIps;
    @TableField(
            updateStrategy = FieldStrategy.IGNORED
    )
    private Long calleePhoneGroupId;        // 举例None
    private Integer calleePhoneGroupType;   // 举例：0
    // 空；021；0755
    private String blackArea;           // 禁呼区域，举例：021
    // 空；021；0755
    private String enableArea;          // 允许外呼区域，举例：021
    // 空
    private Integer status;             // 举例：None
    @JsonIgnore
    @TableField(
            exist = false
    )
    private List<String> calleePhoneGroupSet;   // 实践中，没有手机组
    @JsonIgnore
    @TableField(
            exist = false
    )
    private List<String> callerLimitList;
    private String callerColumn;                 // 举例：none
    private String calleeColumn;                // 举例：none
    private Date createTime;                    // 创建时间
    private Date updateTime;                    // 更新时间

    public GatewayInfo() {
    }

    public GatewayInfo(Long id) {
        this.id = id;
    }

    @JsonIgnore
    public boolean isCallerAllowed() {
        // 实践中，都是返回true
        return Integer.valueOf(0).equals(this.callerLimitType);
    }

    @JsonIgnore
    public boolean isCalleeAllowed() {
        return Integer.valueOf(0).equals(this.calleeLimitType);
    }

    public Long getId() {
        return this.id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Long getAccountId() {
        return this.accountId;
    }

    public void setAccountId(Long accountId) {
        this.accountId = accountId;
    }

    public Integer getCalleeLimitType() {
        return this.calleeLimitType;
    }

    public void setCalleeLimitType(Integer calleeLimitType) {
        this.calleeLimitType = calleeLimitType;
    }

    public String getCalleeLimit() {
        return this.calleeLimit;
    }

    public void setCalleeLimit(String calleeLimit) {
        this.calleeLimit = calleeLimit;
    }

    public Integer getCallerLimitType() {
        return this.callerLimitType == null ? 1 : this.callerLimitType;
    }

    public void setCallerLimitType(Integer callerLimitType) {
        this.callerLimitType = callerLimitType;
    }

    public String getCallerLimit() {
        return this.callerLimit;
    }

    public void setCallerLimit(String callerLimit) {
        this.callerLimit = callerLimit;
    }

    public List<String> getCallerLimitList() {
        if (this.callerLimitList == null) {
            this.callerLimitList = new ArrayList();
            String[] split = this.callerLimit.split(",");
            String[] var2 = split;
            int var3 = split.length;

            for(int var4 = 0; var4 < var3; ++var4) {
                String s = var2[var4];
                this.callerLimitList.add(s);
            }
        }

        return this.callerLimitList;
    }

    public void setCallerLimitList(List<String> callerLimitList) {
        this.callerLimitList = callerLimitList;
    }

    public String getBlackArea() {
        return this.blackArea;
    }

    public void setBlackArea(String blackArea) {
        this.blackArea = blackArea;
    }

    public String getEnableArea() {
        return this.enableArea;
    }

    public void setEnableArea(String enableArea) {
        this.enableArea = enableArea;
    }

    public Integer getStatus() {
        return this.status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Date getCreateTime() {
        return this.createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return this.updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public String getCallerChange() {
        return this.callerChange;
    }

    public void setCallerChange(String callerChange) {
        this.callerChange = callerChange;
    }

    public String getCalleeChange() {
        return this.calleeChange;
    }

    public void setCalleeChange(String calleeChange) {
        this.calleeChange = calleeChange;
    }

    public Integer getConcurrency() {
        return this.concurrency == null ? 0 : this.concurrency;
    }

    public void setConcurrency(Integer concurrency) {
        this.concurrency = concurrency;
    }

    public LocalTime getCallTimeStart() {
        return this.callTimeStart;
    }

    public void setCallTimeStart(LocalTime callTimeStart) {
        this.callTimeStart = callTimeStart;
    }

    public LocalTime getCallTimeEnd() {
        return this.callTimeEnd;
    }

    public void setCallTimeEnd(LocalTime callTimeEnd) {
        this.callTimeEnd = callTimeEnd;
    }

    public Integer getPriority() {
        return this.priority == null ? 1 : this.priority;
    }

    public void setPriority(Integer priority) {
        this.priority = priority;
    }

    public String getCallerLengthLimit() {
        return this.callerLengthLimit;
    }

    public void setCallerLengthLimit(String callerLengthLimit) {
        this.callerLengthLimit = callerLengthLimit;
    }

    public String getCalleeLengthLimit() {
        return this.calleeLengthLimit;
    }

    public void setCalleeLengthLimit(String calleeLengthLimit) {
        this.calleeLengthLimit = calleeLengthLimit;
    }

    public Long getCalleePhoneGroupId() {
        return this.calleePhoneGroupId;
    }

    public void setCalleePhoneGroupId(Long calleePhoneGroupId) {
        this.calleePhoneGroupId = calleePhoneGroupId;
    }

    public Integer getCalleePhoneGroupType() {
        return this.calleePhoneGroupType;
    }

    public void setCalleePhoneGroupType(Integer calleePhoneGroupType) {
        this.calleePhoneGroupType = calleePhoneGroupType;
    }

    public List<String> getCalleePhoneGroupSet() {
        return this.calleePhoneGroupSet;
    }

    public void setCalleePhoneGroupSet(List<String> calleePhoneGroupSet) {
        this.calleePhoneGroupSet = calleePhoneGroupSet;
    }

    @JsonIgnore
    public boolean isCalleeGroupAllowed() {
        return Integer.valueOf(0).equals(this.calleePhoneGroupType);
    }

    public String getCallerColumn() {
        return this.callerColumn;
    }

    public void setCallerColumn(String callerColumn) {
        this.callerColumn = callerColumn;
    }

    public String getCalleeColumn() {
        return this.calleeColumn;
    }

    public void setCalleeColumn(String calleeColumn) {
        this.calleeColumn = calleeColumn;
    }

    public List<String> getFsServerIps() {
        return this.fsServerIps;
    }

    public void setFsServerIps(List<String> fsServerIps) {
        this.fsServerIps = fsServerIps;
    }

    public String toString() {
        return (new StringJoiner(", ", "[", "]")).add("id=" + this.id).add("name='" + this.name + "'").add("callerLimitType='" + this.callerLimitType + "'").add("callerLimit='" + this.callerLimit + "'").add("calleeLimitType='" + this.calleeLimitType + "'").add("concurrency='" + this.concurrency + "'").add("callTimeStart='" + this.callTimeStart + "'").add("callTimeEnd='" + this.callTimeEnd + "'").add("priority='" + this.priority + "'").toString();
    }
}
